package leetcode.code0645;

import java.util.Arrays;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public int[] findErrorNums(int[] nums) {
		Arrays.sort(nums);
		int[] ans = new int[2];
		int p = 0, last = -1;
		for (int num : nums) {
			if (num == last) {
				ans[0] = num;
			}
			last = num;
			if (num == p + 1) {
				p = num;
			}
		}
		ans[1] = p + 1;
		return ans;
	}

	@Override
	public void debug4() {
		HelpDebug.compare(HelpDebug.str2array3("[2,10]"), this.findErrorNums(HelpDebug.str2array3("[1,5,3,2,2,7,6,4,8,9]")));
		HelpDebug.compare(HelpDebug.str2array3("[3,1]"), this.findErrorNums(HelpDebug.str2array3("[3,2,3,4,6,5]")));
		HelpDebug.compare(HelpDebug.str2array3("[2,3]"), this.findErrorNums(HelpDebug.str2array3("[1,2,2,4]")));
		HelpDebug.compare(HelpDebug.str2array3("[1,2]"), this.findErrorNums(HelpDebug.str2array3("[1,1]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
